home *** CD-ROM | disk | FTP | other *** search
- Path: omni2.voicenet.com!not-for-mail
- From: jchris@voicenet.com (John L. Christopher)
- Newsgroups: comp.lang.c++
- Subject: Re: Bletcherous kludge!
- Date: 5 Apr 1996 13:20:55 -0500
- Organization: Voicenet - Internet Access - (215)674-9290
- Message-ID: <4k3oa7$9e6@omni2.voicenet.com>
- NNTP-Posting-Host: omni2.voicenet.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- In response to the problem of converting a null terminated character
- array Buffer (defined within the class String) into a floating point
- number -
-
-
- An appropriate and totally C++ solution might be
-
- #include <strstream.h>
- .
- .
- double String::Number() {
- double val;
- istrstream ist(Buffer);
-
- ist >> val;
- return val;
- }
-
- This uses the string stream facility of the language to use memory
- buffers as i/o sources and sinks (similar to the sprintf function
- of C).
-